import * as React from "react";
import { observer } from "mobx-react";
import { toJS } from "mobx";
import classnames from "classnames";
import jQuery from "jquery";
import _ from 'lodash';
import { Button, Popover, message } from 'antd';
import {  WeaLocaleProvider,  WeaSelect,  WeaTools,} from 'ecCom';
import { spellResourceCondition } from "../excel-layout/cell-field/browser-element/Browser";
import ButtonNew from '../commonComs/buttonNew';
import SelectNew from '../commonComs/selectNew';
import InputNew from '../commonComs/inputNew';
import DateGroupNew from '../commonComs/DateGroupNew';
import TimeRangePickerNew from '../commonComs/TimeRangePickerNew';
import RangePickerNew from '../commonComs/RangePickerNew';
import SelectGroupNew from '../commonComs/SelectGroupNew';
import BrowserNew from '../commonComs/BrowserNew';

const getLabel = WeaLocaleProvider.getLabel;
export const getTimedata = () => {
    return [
        { name: getLabel(332, '全部'), value: '0' },
        { name: getLabel(517615, '昨天'), value: '9' },
        { name: getLabel(15537, '今天'), value: '1' },
        { name: getLabel(517616, '明天'), value: '10' },
        { name: getLabel(517617, '上周'), value: '11' },
        { name: getLabel(15539, '本周'), value: '2' },
        { name: getLabel(517618, '下周'), value: '12' },
        { name: getLabel(15541, '本月'), value: '3' },
        { name: getLabel(21904, '本季'), value: '4' },
        { name: getLabel(15384, '本年'), value: '5' },
        { name: getLabel(27347, '上个月'), value: '7' },
        { name: getLabel(81716, '上一年'), value: '8' },
        { name: getLabel(32530, '指定日期范围'), value: '6' }  // 时间范围的值必须为6
    ]
};

const hrmoptions = [
    { key: "0", showname: getLabel(332, '全部') },
    { key: "-1", showname: getLabel(21837, '本部门') },
    { key: "-2", showname: getLabel(81362, '本部门(包含下级部门)') },
    { key: "-3", showname: getLabel(30792, '本分部'), visible: true },
    { key: "-4", showname: getLabel(81363, '本分部(包含下级分部)') },
    { key: "-6", showname: getLabel(15763, '本人') },
    { key: "-7", showname: getLabel(15709, '直接上级') },
    { key: "-8", showname: getLabel(81863, '直接下属') },
    { key: "-5", showname: getLabel(33210, '选择人员') }
];

interface QuickSearchProps {
    datas,
    listStore,
    onChange,
}

/****处理快捷搜索 */
@observer
export default class QuickSearch extends React.Component<QuickSearchProps, any> {

    componentDidMount(): void {
        const { datas = [] } = this.props;
        if (datas.length) {
            this.onHideGroupPanel('.coms-mode-docker', datas);
        }
    }

    /**
     * @description 由于分组内的组件会弹出模态框，当点击内部的模态框时，应维持分组的展示，只有点击
     * 非分组相关区域时，才关闭分组的模态框展示。
     * */
    onHideGroupPanel = (classname, datas = []) => {
        if (datas.some((item: any) => item.hasOwnProperty('searchGroup'))) {//快捷搜索有分组才适用
            jQuery(classname).on('click', () => {      //点击非分组卡片区域，如果分组为显示状态,关闭卡片
                if (jQuery('.ant-popover.cube-quicksearch-group-popover').not('.ant-popover-hidden').css('display') == 'block') {
                    if (datas.some((data: any) => data.hasOwnProperty('_visible') && data._visible)) {
                        this.setGroupVisible('', false);
                    }
                }
            });
        }
    };

    /**
     * 分组显隐
     * */
    setGroupVisible = (id, isShow) => {
        const { datas, listStore } = this.props;
        let { setQuickSearchInfo } = listStore;
        const newData = datas.map((item) => {
            const { groupid } = item;
            if (groupid == id) {
                item['_visible'] = isShow;
            } else {
                item['_visible'] = false;
            }
            return item;
        });
        setQuickSearchInfo(newData);
    };

    /**
     * 表单项修改
     * */
    onValueChange = (fieldid, value, doNotSearch: boolean) => {
        this.props.onChange(fieldid, value, doNotSearch);//如果是分组则记录,true form记录但不发起搜索
    };

    /**
     * 判断分组的内部的组件是否选择了值
     * */
    getGroupChecked = (data, index, QSDataObj): boolean => {
        return data.searchGroup.some((item: any) => {
            const sourceData = QSDataObj[index];
            if (sourceData) {
                for (let i = 0, len = sourceData.searchGroup.length; i < len; i++) {
                    const tmpdata = sourceData.searchGroup[i];
                    const { fieldid, fieldhtmltype, fieldtype, value = '', replaceDatas = [] } = item;
                    if (fieldid == tmpdata.fieldid) {
                        if (item.hasOwnProperty('value')) {
                            //默认值或初始值特殊 的情况
                            if ((fieldhtmltype == '1' && fieldtype != '1')//数值类型
                                || (fieldhtmltype == '5' && fieldtype == '1')//下拉框
                                || (fieldhtmltype == '4' && fieldtype == '1') //勾选框
                                || (fieldhtmltype == '5' && fieldtype == '2') //多选框
                                || (fieldhtmltype == '5' && fieldtype == '3') //单选框
                            ) {
                                if (value == '-1') {   // 默认值可能更改为-1
                                    return false;
                                }
                            } else if (fieldhtmltype == '3' && fieldtype == '1') {//人员 ["-5",""]||[]
                                if (!value[0]) {
                                    return false;
                                }
                                if (value[0] == '-5') {
                                    if (_.isEmpty(value[1])) {
                                        return false;//默认值 ["-5",""]||["-5",[]]
                                    } else if (_.isArray(value[1]) && !value[1][0]) {
                                        return false;//["-5",['','',empty]]
                                    }
                                } else if (value[0] == '0' && !value[1]) {//全部 ["0", null]
                                    return false;
                                }
                            } else if (fieldhtmltype == '3' && fieldtype == '2') {//创建日期
                                if (!value[0] || value[0] == '0') {
                                    return false;//value: ["0", "", ""]||value: ["0"]
                                } else if (value[0] == '6' && !value[1]) {//指定日期范围['6']
                                    return false;
                                }
                            }
                            //通常情况
                            if (_.isEqual(toJS(value), toJS(tmpdata['value']))) {//与原始后台数据相等
                                return false;
                            } else if (!toJS(value)) {//空
                                return false;
                            } else if (_.isArray(toJS(value))) {
                                if (_.isEmpty(toJS(value)) || value[0] == '') {//[]||[""]
                                    return false;
                                }
                            }
                        } else if (item.hasOwnProperty('replaceDatas')) {
                            if (_.isEmpty(toJS(replaceDatas)) || replaceDatas[0] == '') {//如果数组为空或第一项是空值
                                return false;
                            } else if (_.isEqual(toJS(replaceDatas), toJS(tmpdata['replaceDatas']))) {//如果与原始数据相同
                                return false;
                            }
                        } else if (!item.hasOwnProperty('value') && !item.hasOwnProperty('replaceDatas')) {
                            return false;
                        }
                        return true;
                    }
                }
            }
            return false;
        });
    };

    /**
     * 重置
     * */
    resetConditions = (groupid) => {
        const { listStore } = this.props;
        let { quickSearchFormData, quickSearchData, quickSearchDataWithNoChange, setQuickSearchInfo } = listStore;
        const QSDataObj = quickSearchDataWithNoChange && JSON.parse(quickSearchDataWithNoChange);//原始数据作为初始值
        const info = quickSearchData.quicksearchinfo.map(data => {
            if (data.groupid == groupid) {
                data = QSDataObj.filter(em => em.groupid == groupid)[0];
                data['_visible'] = false;
                data.searchGroup.map(item => {
                    const { fieldid = '' } = item;
                    _.set(quickSearchFormData, fieldid, '');
                    listStore.changeConditioninfo(fieldid, '');
                })
            }
            return data;
        });
        setQuickSearchInfo(info);
        this.props.onChange('', '', false)
    };

    /**
     * 搜索
     * */
    doGroupSearch = (groupid) => {
        this.props.onChange('', '', false);//form do search
        this.setGroupVisible(groupid, false)
    };

    getFields = (field: any, conditioninfo) => {
        const { listStore } = this.props;
        let { quickSearchFormData } = listStore;
        if (field.parentDomkey && field.parentDomkey.length > 0) {
            let items: any = {};
            conditioninfo.map(f => {
                if (f.domkey == field.parentDomkey[0]) {
                    const domkeyValue = f.domkey[0].split('_')[1];
                    const value1 = quickSearchFormData[domkeyValue] ? quickSearchFormData[domkeyValue] : WeaTools.getSelectDefaultValue(f.options);
                    let childitem: any = [];
                    value1.split(',').map((val) => {
                        childitem = _.union(childitem, f.options.filter(o => o.key == val))
                    });
                    let childitemid: any = [];
                    childitem.map((item) => {
                        childitemid = _.union(childitemid, item.childitemid)
                    });
                    let childArry: any = [];
                    for (let i = 0; i < childitemid.length; i++) {
                        const arr = field.options.filter(option => option.key == childitemid[i] || option.key == "");
                        childArry = _.union(childArry, arr);
                    }
                    field = { ...field, options: childArry };
                }
                items = field;
            });
            return items
        } else {
            return field;
        }
    };

    renderGroup = (data, data_index, getRender) => {
        const { listStore } = this.props;
        let { quickSearchDataWithNoChange } = listStore;
        const QSDataObj = quickSearchDataWithNoChange && JSON.parse(quickSearchDataWithNoChange);

        const { groupname = '筛选条件' } = data;
        const { _visible = false } = data;
        const ghostChecked: boolean = this.getGroupChecked(data, data_index, QSDataObj);
        const cont = (
            <div className="cube-quicksearch-group">
                {getRender(data.searchGroup, true)}
                <div className='cube-quicksearch-funbtn'>
                    <ButtonNew type='ghost' content={getLabel(2022, '重置')} id={data.groupid}  onClick={this.resetConditions} />
                    <ButtonNew type='primary' content={getLabel(388113, '搜索')} id={data.groupid}  onClick={this.doGroupSearch} />
                </div>
            </div>
        );
        return (<Popover content={cont} trigger="click" overlayClassName="cube-quicksearch-group-popover"
                         placement="bottomLeft"
                         visible={_visible}
                         onVisibleChange={(v) => v && this.setGroupVisible(data.groupid, true)}
        >
            <div className="cube-quicksearch-group-btn">
                <Button type="ghost" className={classnames('cube-quicksearch-group-mainbtn', { 'cube-ghostChecked': ghostChecked })}>
                    <span>{groupname}</span>
                    <i className="icon-coms-down2"/>
                </Button>
            </div>
        </Popover>);
    }

    render(): React.ReactNode {
        const { datas, listStore } = this.props;
        let { quickSearchFormData, quickSearchConditionData } = listStore;
        const { quickSearchData: { ishidename, isshowtype } } = listStore;
        const showInOneLine = isshowtype === '0';//是否为一行显示
        let divstyle = { display: 'inline-block', margin: '2px 10px' };
        let copyReplaceData: any = [];
        let copyData = datas;
        let Timedata = getTimedata();

        /**
         * 记录快捷搜索填入的值
         * */
        const setCopyReplaceData = (fieldid, v, keyName = 'value') => {
            copyReplaceData.map((itemss, findex) => {
                if (itemss.hasOwnProperty('searchGroup')) {
                    itemss.searchGroup.map((dd, inx) => {
                        if (dd.fieldid == fieldid) {
                            copyReplaceData[findex]['searchGroup'][inx][keyName] = v;
                        }
                    })
                } else {
                    if (itemss.fieldid == fieldid) {
                        copyReplaceData[findex][keyName] = v;
                    }
                }
            });
        };

        const  onPressEnter = (fieldid,v,isChild)=>{
            setCopyReplaceData(fieldid, v);
            listStore.changeConditioninfo(fieldid, v);
            this.onValueChange(fieldid, v, isChild);
        }

        const onBlur = (fieldid,v,isChild)=>{
            setCopyReplaceData(fieldid, _.trim(v));
            listStore.changeConditioninfo(fieldid, v);
            v != _.get(quickSearchFormData, fieldid, '') && this.onValueChange(fieldid, v, isChild);
            _.set(quickSearchConditionData, "con_" + fieldid, v);
        }

        const selectGroupChange = (fieldid,v,isChild) => {
            if (_.isArray(v) && v[0] != '-5') {
                v = [v[0], []];
            }
            setCopyReplaceData(fieldid, v);
            listStore.changeConditioninfo(fieldid, v);
            this.onValueChange(fieldid, v, isChild);
            _.set(quickSearchConditionData, "con_" + fieldid, v);
        }

        const BrowserChange = (ids, names, datas,fieldtype,fieldid,isChild) => {
            let valueSpan = "";
            let data: any = [];
            try {
                if (fieldtype == '141') {
                    ids = spellResourceCondition(datas);
                    valueSpan = names + ",";
                    datas.map(it => {
                        data.push(it);
                    })
                } else {
                    datas.map(it => {
                        const { name } = it;
                        valueSpan += name + ",";
                        for (let k in it) {
                            if (k == 'id' || k == 'name') {

                            } else {
                                delete it[k];
                            }
                        }
                        it["tips"] = name;
                        it["count"] = 0;
                        data.push(it)
                    });
                }

                valueSpan = valueSpan.substring(0, valueSpan.length - 1);
                listStore.changeConditioninfoForBrowser(fieldid, ids, data, valueSpan);
            } catch (e) {
                listStore.changeConditioninfoForBrowser(fieldid, ids, data, valueSpan);
            }
            let replaceData: any = [];
            if (ids.indexOf(",") > -1) {
                let BValue = ids.split(",");
                let dataAny = names.split(",");
                let datas = {};
                let i = 0;
                BValue.map(item => {
                    datas = { id: item, name: dataAny[i] };
                    replaceData.push(datas);
                    i++;
                });
            } else {
                replaceData = [{ id: ids, name: names }];
            }
            if (fieldtype == '141') {
                replaceData = datas;
            }

            setCopyReplaceData(fieldid, replaceData, 'replaceDatas');

            this.onValueChange(fieldid, ids, isChild);
            _.set(quickSearchConditionData, "con_" + fieldid, ids);
        }


        /**
         * 渲染快捷搜索表单
         * */
        const getRender = (copyData, isChild = false) => {
            return copyData.map((data, data_index) => {
                if (!isChild) {
                    copyReplaceData.push(data);
                }
                //处理分组
                if (data.hasOwnProperty('searchGroup')) {
                    return this.renderGroup(data, data_index, getRender);
                }
                //不分组
                let {
                    fieldtype, fieldhtmltype, fieldid, customname, browserProps, value = "", detailtype, multiple, viewAttr,
                    replaceDatas = [], conditiontransition, floatValue, requiredCon, showmodel
                } = data;
                const isflatlay = showmodel === '1';//是否是平铺
                let colonStr = '';
                const title = isChild && showInOneLine ? { title: customname } : {};
                if (_.get(listStore.quickSearchConditionData, "con_" + fieldid) == undefined) {
                    _.set(listStore.quickSearchConditionData, "con_" + fieldid, "");
                }

                if (customname) { //如果没有labelname则不显示冒号
                    colonStr = (WeaLocaleProvider.getUserLanguage() == 7 || WeaLocaleProvider.getUserLanguage() == 9) ? '：' : ':';
                }
                if ((fieldhtmltype == '1' && fieldtype != '1')//数值类型
                    || (fieldhtmltype == '5' && fieldtype == '1')//下拉框
                    || (fieldhtmltype == '4' && fieldtype == '1') //勾选框
                    || (fieldhtmltype == '5' && fieldtype == '2') //多选框
                    || (fieldhtmltype == '5' && fieldtype == '3') //单选框
                ) {
                    if (requiredCon == '1' && (value == undefined || value == '-1' || value == -1)) {
                        value = '';
                    }
                    if (value != undefined && _.get(quickSearchFormData, fieldid, "-1") == -1) {
                        _.set(quickSearchFormData, fieldid, value)
                    }
                    data = this.getFields(data, copyData);
                    const onNumSelect = (v) => {
                        setCopyReplaceData(fieldid, v);
                        if (v == "-1" || v == "") {
                            listStore.changeConditioninfo(fieldid, []);
                        } else {
                            let float: any;
                            float = floatValue;
                            let i: any = float[v].split(",");
                            listStore.changeConditioninfo(fieldid, i);
                        }
                        this.onValueChange(fieldid, v, isChild);
                        _.set(quickSearchConditionData, "con_" + fieldid, v);
                    };
                    const onSelectWithDeatilType = (v, detailtype, multiple) => {
                        setCopyReplaceData(fieldid, v);
                        listStore.changeConditioninfo(fieldid, v);
                        this.onValueChange(fieldid, v, isChild);
                        _.set(quickSearchConditionData, "con_" + fieldid, v);

                    };
                    const onSelectChange = (v, detailtype, multiple) => {
                        setCopyReplaceData(fieldid, v);
                        listStore.changeConditioninfo(fieldid, v);
                        this.onValueChange(fieldid, v, isChild);
                        _.set(quickSearchConditionData, "con_" + fieldid, v);

                    };

                    /******** start:   平铺模式参数 * (只支持数值类型或下拉框) *******/
                    let cls: any = '', style: any = { width: 100 };
                    let supportCancel: boolean = false;//单选是否支持取消
                    if (isflatlay) {
                        detailtype = detailtype == '2' ? 2 : multiple ? 2 : 3;  //平铺下，2多选，3单选
                        supportCancel = detailtype === 3;
                        cls = 'cube-quicksearch-flat-lay';
                        style = {};
                        if (data.options.every(item => !item.showname)) {
                            return (<div style={{ ...divstyle }}>
                                {!ishidename &&
                                <span
                                    className={classnames('cube-quicksearch-label', { 'cube-quicksearch-label-wrap': !showInOneLine })}
                                    style={{ marginRight: 5 }}>{customname}{colonStr}</span>}
                                <div
                                    className={classnames('cube-quicksearch-style', { 'cube-quicksearch-in-one-line': showInOneLine })}>
                                    <div className='cube-group-empty'>
                                        <span>{getLabel(514133, '未设置')}</span>
                                        <span>{getLabel(386817, '选项')}</span>
                                    </div>
                                </div>
                            </div>)
                        }
                    }
                    /*************************  end  ****************************/
                    if (detailtype != '' && (fieldhtmltype == '1' && fieldtype != '1')) {   //数值类型
                        value = (value == "-1" || value == "") ? "" : value;
                        return (
                            <div style={{ ...divstyle }}>
                                {!ishidename &&
                                <span {...title}
                                      className={classnames('cube-quicksearch-label', { 'cube-quicksearch-label-wrap': !showInOneLine })}
                                      style={{ marginRight: 5 }}>{customname}{colonStr}</span>}
                                <div
                                    className={classnames('cube-quicksearch-style', { 'cube-quicksearch-in-one-line': showInOneLine })}>
                                    <WeaSelect
                                        options={toJS(data.options)}
                                        style={{ ...style, verticalAlign: 'middle' }}
                                        value={value}
                                        viewAttr={viewAttr}
                                        multiple={multiple}
                                        onChange={onNumSelect}
                                        placeholder={customname}
                                        detailtype={detailtype}
                                        className={cls}
                                        supportCancel={supportCancel}
                                    />
                                </div>
                            </div>
                        )

                    } else if ((fieldhtmltype == '5' && fieldtype == '1') && detailtype != '') {    //下拉框类型
                        const mult = !isflatlay ? { multiple } : {};//如果是平铺则不要multiple属性
                        return (
                            <div style={{ ...divstyle }}>
                                {!ishidename &&
                                <span {...title}
                                      className={classnames('cube-quicksearch-label', { 'cube-quicksearch-label-wrap': !showInOneLine })}
                                      style={{ marginRight: 5 }}>{customname}{colonStr}</span>}
                                <div
                                    className={classnames('cube-quicksearch-style', { 'cube-quicksearch-in-one-line': showInOneLine })}>
                                    <SelectNew
                                        options={toJS(data.options)}
                                        style={{ ...style, verticalAlign: 'middle' }}
                                        value={value}
                                        viewAttr={viewAttr}
                                        {...mult}
                                        placeholder={customname}
                                        className={cls}
                                        supportCancel={supportCancel}
                                        detailtype={detailtype}
                                        multiple={multiple}
                                        onChange={onSelectWithDeatilType}
                                    />
                                </div>
                            </div>)
                    } else {//单选框，多选框，勾选框,现在也显示成下拉框
                        const flatlay = isflatlay ? { detailtype, supportCancel } : {};
                        const mult = !isflatlay && (detailtype == '2' || multiple) ? { multiple: true } : {};
                        const option = isflatlay || (detailtype == '2' || multiple) ? data.options.filter(opt => opt.showname) : data.options;
                        return (
                            <div style={{ ...divstyle }}>
                                {!ishidename &&
                                <span {...title}
                                      className={classnames('cube-quicksearch-label', { 'cube-quicksearch-label-wrap': !showInOneLine })}
                                      style={{ marginRight: 5 }}>{customname}{colonStr}</span>}
                                <div
                                    className={classnames('cube-quicksearch-style', { 'cube-quicksearch-in-one-line': showInOneLine })}>
                                    <SelectNew
                                        options={toJS(option)}
                                        style={{ ...style, verticalAlign: 'middle' }}
                                        value={value}
                                        viewAttr={viewAttr}
                                        multiple={multiple}
                                        onChange={onSelectChange}
                                        placeholder={customname}
                                        className={cls}
                                        {...mult}
                                        {...flatlay}
                                    />
                                </div>
                            </div>)
                    }
                } else if (fieldhtmltype == '1' && fieldtype == '1') {//文本框
                    return <div style={{ ...divstyle }}>
                        {!ishidename && <span {...title}
                                              className={classnames('cube-quicksearch-label', { 'cube-quicksearch-label-wrap': !showInOneLine })}
                                              style={{ marginRight: 20 }}>{customname}{colonStr}</span>}
                        <div
                            className={classnames('cube-quicksearch-style', { 'cube-quicksearch-in-one-line': showInOneLine })}>
                            <InputNew
                                style={{ width: 150, 'vertical-align': 'middle' }}
                                viewAttr={viewAttr}
                                value={value}
                                placeholder={customname}
                                fieldid ={fieldid}
                                isChild={isChild}
                                onChange={setCopyReplaceData}
                                onPressEnter={onPressEnter}
                                onBlur={onBlur}
                            />
                        </div>
                    </div>
                } else if (fieldhtmltype == '2' && fieldtype == '1') {//多行文本框
                    return <div style={{ ...divstyle }}>
                        {!ishidename && <span {...title}
                                              className={classnames('cube-quicksearch-label', { 'cube-quicksearch-label-wrap': !showInOneLine })}
                                              style={{ marginRight: 20 }}>{customname}{colonStr}</span>}
                        <div
                            className={classnames('cube-quicksearch-style', { 'cube-quicksearch-in-one-line': showInOneLine })}>
                            <InputNew
                                style={{ width: 150, 'vertical-align': 'middle' }}
                                viewAttr={viewAttr}
                                value={value}
                                fieldid ={fieldid}
                                isChild={isChild}
                                onChange={setCopyReplaceData}
                                onPressEnter={onPressEnter}
                                onBlur={onBlur}
                                placeholder={customname}
                                
                            />
                        </div>
                    </div>
                } else if (fieldhtmltype == '2' && fieldtype == '2') {//文本html
                    return <div style={{ ...divstyle }}>
                        {!ishidename && <span {...title}
                                              className={classnames('cube-quicksearch-label', { 'cube-quicksearch-label-wrap': !showInOneLine })}
                                              style={{ marginRight: 20 }}>{customname}{colonStr}</span>}
                        <div
                            className={classnames('cube-quicksearch-style', { 'cube-quicksearch-in-one-line': showInOneLine })}>
                            <InputNew
                                style={{ width: 150, 'vertical-align': 'middle' }}
                                viewAttr={viewAttr}
                                value={value}
                                fieldid ={fieldid}
                                isChild={isChild}
                                onChange={setCopyReplaceData}
                                onPressEnter={onPressEnter}
                                onBlur={onBlur}
                                placeholder={customname}
                            />
                        </div>
                    </div>
                } else if (fieldhtmltype == '3') {
                    if (fieldtype == '2') {//日期
                        if (value != undefined && _.get(quickSearchFormData, fieldid) == undefined) {
                            _.set(quickSearchFormData, fieldid, value)
                        }
                        return <div style={{ ...divstyle }}>
                            {!ishidename && <span {...title}
                                                  className={classnames('cube-quicksearch-label', { 'cube-quicksearch-label-wrap': !showInOneLine })}
                                                  style={{ marginRight: 20 }}>{customname}{colonStr}</span>}
                            <div
                                className={classnames('cube-quicksearch-style', { 'cube-quicksearch-in-one-line': showInOneLine })}>
                                <DateGroupNew
                                    isMobx
                                    value={toJS(value)}
                                    style={{ minWidth: 120, display: 'inline-block' }}
                                    datas={Timedata}
                                    viewAttr={viewAttr}
                                    isInline={true}
                                    fieldid ={fieldid}
                                    isChild={isChild}
                                    onChange={onPressEnter}
                                />
                            </div>
                        </div>
                    } else if (fieldtype == '19') {//时间
                        return <div style={{ ...divstyle }}>
                            {!ishidename && <span {...title}
                                                  className={classnames('cube-quicksearch-label', { 'cube-quicksearch-label-wrap': !showInOneLine })}
                                                  style={{ marginRight: 20 }}>{customname}{colonStr}</span>}
                            <div
                                className={classnames('cube-quicksearch-style', { 'cube-quicksearch-in-one-line': showInOneLine })}>
                                <TimeRangePickerNew
                                    value={toJS(value)}
                                    noInput={true}
                                    viewAttr={viewAttr}
                                    fieldid ={fieldid}
                                    isChild={isChild}
                                    onChange={onPressEnter}
                                />
                            </div>
                        </div>
                    } else if (fieldtype == '290') {//日期时间
                        return <div style={{ ...divstyle }}>
                            {!ishidename && <span {...title}
                                                  className={classnames('cube-quicksearch-label', { 'cube-quicksearch-label-wrap': !showInOneLine })}
                                                  style={{ marginRight: 20 }}>{customname}{colonStr}</span>}
                            <div
                                className={classnames('cube-quicksearch-style', { 'cube-quicksearch-in-one-line': showInOneLine })}>
                                <RangePickerNew
                                    value={toJS(value)}
                                    style={{ width: 'auto' }}
                                    viewAttr={viewAttr}
                                    format="yyyy-MM-dd HH:mm"
                                    showTime
                                    fieldid ={fieldid}
                                    isChild={isChild}
                                    onChange={onPressEnter}
                                />
                            </div>
                        </div>
                    } else if (fieldtype == '1' || ('1' == conditiontransition && '17' == fieldtype)) {   //人员
                        if (fieldtype == '1' && '1' == conditiontransition) {
                            browserProps = { ...browserProps, isSingle: false };
                            delete browserProps.isMultCheckbox;//qc732353,由于组件库改造浏览框，单部门单分部单人力多选后快捷搜索不能选择多个，删除该属性。
                        }
                        let selectLink = {
                            "-5": {
                                conditionType: "BROWSER",
                                browserConditionParam: { ...browserProps, maxBrowerHeight: 28 },
                                domkey: ['hrmBrowser']
                            }
                        };
                        let vs = [...value];
                        let width = 280;
                        if (vs.length > 0) {
                            if (vs[0] != -5) {
                                width = 130;
                            } else if (vs[0] == -5 && !vs[1]) {//选择人员，值需为数组
                                vs[1] = [];
                            }
                        }
                        return <div className={'hrmSelectGrop searchdiv' + fieldid} style={{ ...divstyle }}>
                            {!ishidename && <span {...title}
                                                  className={classnames('cube-quicksearch-label', { 'cube-quicksearch-label-wrap': !showInOneLine })}
                                                  style={{ marginRight: 20 }}>{customname}{colonStr}</span>}
                            <div   className={classnames('cube-quicksearch-style', { 'cube-quicksearch-in-one-line': showInOneLine })}>
                                <SelectGroupNew
                                    isMobx
                                    value={toJS(value)}
                                    options={hrmoptions}
                                    style={{ width: width, display: 'inline-flex' }}
                                    selectLinkageDatas={selectLink}
                                    fieldid ={fieldid}
                                    isChild={isChild}
                                    onChange={selectGroupChange}
                                />
                            </div>
                        </div>
                    } else {
                        let hasAdvanceSerach = true;
                        let dataParams = browserProps.dataParams || {};
                        let conditionDataParams = browserProps.conditionDataParams || {};
                        let completeParams = browserProps.completeParams || {};
                        if (fieldtype == '256' || fieldtype == '257') {
                            //disabledInput = true;//树形不支持快捷搜索
                            hasAdvanceSerach = browserProps.hasAdvanceSerach;
                        }
                        let iconStyle: any = {};
                        if (fieldtype == '256' || fieldtype == '257') {  //自定义树形单多选浏览框图标可以用户自定义
                            let treeId = dataParams.cube_treeid;
                            delete dataParams.cube_treeid;
                            dataParams.cube_treeid = treeId + "_searchType";
                            iconStyle.icon = listStore.iconInfo.icon;
                            iconStyle.iconBgcolor = listStore.iconInfo.iconBg;
                            iconStyle.iconFontColor = listStore.iconInfo.iconColor;
                        }
                        if ((fieldtype == '4' && '1' == conditiontransition) || (fieldtype == '164' && '1' == conditiontransition)) {
                            delete browserProps.isMultCheckbox;//qc732353,由于组件库改造浏览框，单部门单分部单人力多选后快捷搜索不能选择多个，删除该属性。
                            browserProps = { ...browserProps, isSingle: false };
                        }
                        if ((fieldtype == '161' || fieldtype == '162') && replaceDatas != undefined) {
                            //处理自定义单、多选浏览框设置默认值未初始化
                            let quickSearchValue = ""; //replaceDatas[0].id;
                            replaceDatas.map(item => {
                                const { id } = item;
                                quickSearchValue += id + ",";
                            });
                            quickSearchValue = quickSearchValue.substring(0, quickSearchValue.length - 1);
                            _.set(listStore.quickSearchConditionData, "con_" + fieldid, quickSearchValue);
                        }

                        //剔除replaceDatas属性,这里不存储值,不剔除会导致选择后数据丢失,单选，多选，树形单选，树形多选不剔除
                        //if(undefined==browserProps.replaceDatas&&0==browserProps.replaceDatas.length){
                        try {
                            delete browserProps.replaceDatas
                        } catch (error) {
                            message.error(error);
                            throw error;
                        }
                        dataParams = { ...dataParams, ...quickSearchConditionData, consearch: "consearch" };
                        conditionDataParams = {
                            ...conditionDataParams, ...quickSearchConditionData,
                            consearch: "consearch"
                        };
                        completeParams = { ...completeParams, ...quickSearchConditionData, consearch: "consearch" };

                        return <div style={{ ...divstyle }}>
                            {!ishidename && <span {...title}
                                                  className={classnames('cube-quicksearch-label', { 'cube-quicksearch-label-wrap': !showInOneLine })}
                                                  style={{ marginRight: 20 }}>{customname}{colonStr}</span>}
                            <div style={{ width: 150, verticalAlign: 'middle' }}
                                 className={classnames('wea-input-normal', 'cube-quicksearch-style',
                                     { 'cube-quicksearch-in-one-line': showInOneLine })}>
                                <BrowserNew
                                    {...browserProps}
                                    inputStyle={{ width: 150 }}
                                    dataParams={dataParams}
                                    conditionDataParams={conditionDataParams}
                                    completeParams={completeParams}
                                    replaceDatas={replaceDatas}
                                    type={fieldtype}
                                    //disabledInput={disabledInput}
                                    resize={false}
                                    maxBrowerHeight={28}
                                    hasAdvanceSerach={hasAdvanceSerach}
                                    scrollx={true}
                                    viewAttr={viewAttr}
                                    fieldid ={fieldid}
                                    isChild={isChild}
                                    onChange={BrowserChange}
                                    {...iconStyle}
                                />
                            </div>
                        </div>
                    }
                }
            })
        };
        let items = getRender(copyData);
        return <div id="btnDiv">{items}</div>;
    }
   
}
